"""
信号场景：
1.True False
2.2,1,0,-1,-2  默认
3.关心的数据情形？
key 监控值  默认值？

应该是信号组的去重问题：

"""
class signal_drop_duplicates:
    def __init__(self,signal_keys):
        self.signal_keys=signal_keys
        self.pre_b = []
        for i in range(len(signal_keys)):
            self.pre_b.append(None)
        if isinstance(signal_keys,list):
            self.oncalc=self.oncalc_TrueFalse
        else:
            self.oncalc = self.oncalc_self
    def oncalc_TrueFalse(self, b):
        rsts = []
        n=0
        for i in self.signal_keys:
            a=b.get(i,None)
            prea=self.pre_b[n]
            if a==True and prea==True:
                rst=False
            else:
                rst=a
            rsts.append(rst)
            self.pre_b[n] = a
            n=n+1
        return rsts
    def oncalc_self(self, b):
        rsts = []
        n=0
        for k,v in self.signal_keys.items():
            a=b.get(k,None)
            prea=self.pre_b[n]
            if a==v[0] and prea==v[0]:
                rst=v[1]
            else:
                rst=a
            rsts.append(rst)
            self.pre_b[n] = a
            n=n+1
        return rsts